<template>
	<view class="page">
		<view class="searchInput">
				<view class="input">
					<u-search :show-action="false" placeholder="请输入商品关键词搜索" bg-color="#fff" v-model="paramsObj.keyword" @search="searchGoods" shape="round"></u-search>
				</view>
				<text @click="searchGoods">搜索</text>
		</view>
			
			<scroll-view scroll-y="true" style="height: 84vh;" @scrolltolower="scrolltolower" >
				<view>
					<view class="goodsArr">
						<view class="goodsArrItem" v-for="(item,index) in goodsList" :key="index" @click="junit('/pages/tabShop/goodsDetail/goodsDetail' , {id: item.sku_id})">
							<view class="cover">
								<u-image    width="180" height="180" lazy-load :src="item.goods_image" :fade="true" duration="450">
									<u-loading slot="loading"></u-loading>
								</u-image>
							</view>
					
							<view class="info">
								<view class="name">
									{{item.goods_name}}
								</view>
								<view class="bottom-box">
									<view class="desc">
										<text class="price">￥{{item.price}}</text>
										<text>已售{{item.sale_num}}</text>
									</view>
									<view class="jifen">
										2299.00积分兑换
									</view>
								</view>
							</view>
							
						</view> 
					</view>
				</view>
			</scroll-view>
		
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				goodsList:[],
				page: 1 ,
				swiperArr:[],
				keyword:'',
				paramsObj:{
					page : 1,
					page_size : 10,
					keyword : '',//关键词
					category_id: '',//分类id
					min_price: '',//最小价格
					min_price: '',//最大价格
					is_free_shipping:'',//是否包邮(0否1是)
					order:'',//筛选(留空全部 sale_num按销量 discount_price按价格)
					sort: 'desc',//排序(asc 正序 desc 倒序)
					coupon: 0,
					goods_id_arr: 0,
				},
			};
		},
		onLoad() {
			this.init()
		},
		methods:{
			searchGoods(value){
				console.log(value);
				this.paramsObj.page = 1,
				this.getGoodsList()
			},
			scrolltolower(){
				this.paramsObj.page++;
				this.getGoodsList()
			},
			init(){
				this.getGoodsList()
			},
			getGoodsList(){
				if(this.paramsObj.page==1){
					this.goodsList = []
				}
				this.myHttp({
					url:'/api/goodssku/page',
					data: this.paramsObj,
				}).then((res)=>{
						this.goodsList = this.goodsList.concat(res.data.list)
				})
			},
		},
		components:{
		},
		filters:{
			
		},
	}
</script>

<style lang="scss" scoped>
.page{
	width: 100%;
	background-color: #F2F2F2;
	.searchInput{
		width: 100%;
		@include flexCenter;
		padding: 20rpx 30rpx;
		.input{
			@include flexCenter;
			flex: 1;
			height: 68rpx;
			background: #FFFFFF;
			border-radius: 28rpx;
		}
		text{
			margin-left: 20rpx;
		}
	}
	
	
	.goodsArr{
			margin-top: 30rpx;
			display: flex;
			flex-direction: column;
			flex-wrap: wrap;
			justify-content: space-between;
			background-color: #F5F5F5;
			padding: 0rpx 25rpx 50rpx;
			.goodsArrItem{
				width: 100%;
				background: #FFFFFF;
				border-radius: 10rpx;
				margin-top: 15rpx;
				display: flex;
				.cover{
					height: 220rpx;
					width: 220rpx;
					border-radius: 10rpx;
					@include flexCenter;
				}
				image{
					height: 200rpx;
					width: 200rpx;
					border-radius: 10rpx;
				}
				.info{
					@include flexCol;
					flex: 1;
					.name{
						flex: 1;
						font-size: 23rpx;
						color: #000;
						margin: 20rpx 10rpx;
						display: -webkit-box;    
						-webkit-box-orient: vertical;    
						-webkit-line-clamp: 2;    
						overflow: hidden;
					}
					.bottom-box{
						width: 100%;
						display: flex;
						align-items: center;
						justify-content: space-between;
						margin-bottom: 20rpx;
						height: 50rpx;
						.desc{
							color: #A8A8A8;
							font-size: 22rpx;
							@include flexBetween(0rpx 20rpx);
							.price {
								font-size: 26rpx;
								color: #E9612B;
								margin-right: 30rpx;
							}
						}
						.jifen{
							width: 206rpx;
							height: 36rpx;
							background: #FCF1E0;
							border-radius: 18rpx;
							font-size: 22rpx;
							@include flexCenter;
							margin: 10rpx  10rpx 20rpx;
							color: #CFA972;
						}
					}
					
				}
				
			}
	}
}
</style>
